package com.ruoyi.answerRecord.domain;

import com.ruoyi.question.domain.QuestionInfo;
import lombok.Data;

@Data
public class QuizAnswerCheckResultDto {

    private QuizAnswerStatus status;           // 答题状态
    private UserQuizAnswerRecord answerRecord; // 答题记录（如果已答题）
    private QuestionInfo questionInfo;         // 题目信息
    private String message;                    // 提示信息

    public static QuizAnswerCheckResultDto notAnswered(QuestionInfo questionInfo) {
        QuizAnswerCheckResultDto result = new QuizAnswerCheckResultDto();
        result.setStatus(QuizAnswerStatus.NOT_ANSWERED);
        result.setQuestionInfo(questionInfo);
        result.setMessage("可以开始答题");
        return result;
    }

    public static QuizAnswerCheckResultDto alreadyAnswered(UserQuizAnswerRecord record, QuestionInfo questionInfo) {
        QuizAnswerCheckResultDto result = new QuizAnswerCheckResultDto();
        result.setStatus(record.getIsCorrect() == 1 ? QuizAnswerStatus.ANSWERED_CORRECT : QuizAnswerStatus.ANSWERED_WRONG);
        result.setAnswerRecord(record);
        result.setQuestionInfo(questionInfo);
        result.setMessage(record.getIsCorrect() == 1 ? "您已答对此题" : "您已答错此题");
        return result;
    }
}
